package com.itboye.mengwu.data.presenter;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IMePingLunINterfaces;
import com.itboye.mengwu.data.model.MePingLunbean;
import com.itboye.mengwu.data.repository.MePingLunrepository;

import java.util.List;
import java.util.Observer;

public class MePingLunpter extends BasePresenter implements IMePingLunINterfaces<MePingLunbean>{
	public static final String MePingLunSuccessEvent = MainPresenter.class
			.getName() + "_MePingLun_success";
	public static final String MePingLunFailEvent = MainPresenter.class
			.getName() + "_MePingLun_failure";
	
	public static final String DianZanMeSuccessEvent = MainPresenter.class
			.getName() + "_DianZanMe_success";
	public static final String DianZanMeFailEvent = MainPresenter.class
			.getName() + "_DianZanMe_failure";
	public static final String HuiFuMeSuccessEvent=MainPresenter.class
			.getName() + "_HuiFuMe_Success";
	public static final String HuiFuMeFailEvent=MainPresenter.class
			.getName() + "_HuiFuMe_Fail";
	public static final String  MeHuiFuSuccessEvent=MainPresenter.class
			.getName() + "_MeHuiFu_Success";
	public static final String MeHuiFuFailEvent=MainPresenter.class
			.getName() + "_MeHuiFu_Fail";

	public MePingLunpter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(MePingLunbean model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void delete(MePingLunbean model) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update(MePingLunbean model) {
		// TODO Auto-generated method stub
		IMePingLunINterfaces<MePingLunbean> redBag = new MePingLunrepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(MePingLunSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(MePingLunFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.update(model);
	}

	@Override
	public void getInfo(MePingLunbean model) {
		// TODO Auto-generated method stub
		IMePingLunINterfaces<MePingLunbean> redBag = new MePingLunrepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(MePingLunSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(MePingLunFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.getInfo(model);
	}

	@Override
	public List<MePingLunbean> queryYouHuiQuan(MePingLunbean model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void dianzanMe(String uid,String pageNo) {
		// TODO Auto-generated method stub
		IMePingLunINterfaces<MePingLunbean> redBag = new MePingLunrepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(DianZanMeSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(DianZanMeFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.dianzanMe(uid,pageNo);
	}

	@Override
	public void huiFuWo(String uid, String pageNo, int pageSize) {
		IMePingLunINterfaces<MePingLunbean> redBag = new MePingLunrepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(HuiFuMeSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(HuiFuMeFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.huiFuWo(uid,pageNo,pageSize);
	}

	@Override
	public void woHuiFu(String uid, String pageNo, int pageSize) {
		IMePingLunINterfaces<MePingLunbean> redBag = new MePingLunrepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(MeHuiFuSuccessEvent);
						setChanged();
						notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(MeHuiFuFailEvent);
						setChanged();
						notifyObservers(result);
					}
				});
		redBag.woHuiFu(uid,pageNo,pageSize);
	}

}
